cmake_minimum_required(VERSION 3.14)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)

include_directories(
    CMSIS/GD
    GD32F4xx_standard_peripheral/Source
    GD32F4xx_standard_peripheral/Include
    CMSIS
    CMSIS/GD/GD32F4xx/Source/ARM
    CMSIS/GD/GD32F4xx/Include
    CMSIS/GD/GD32F4xx/Source
)


file(GLOB_RECURSE DRIVER_FILES
    gd32f4xx_libopt.h
    GD32F4xx_standard_peripheral/Source/*.c
    GD32F4xx_standard_peripheral/Include/*.h
    CMSIS/core_cm4.h
    CMSIS/core_cm4_simd.h
    CMSIS/core_cmFunc.h
    CMSIS/core_cmInstr.h
    CMSIS/GD/GD32F4xx/Include/gd32f4xx.h
    )

set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS}
    -c --cpu Cortex-M4.fp -g -O0 --apcs=interwork --split_sections"
    )
set(CMAKE_ASM_FLAGS "--cpu Cortex-M4.fp -g --apcs=interwork"
    )

add_library(drivers  ${DRIVER_FILES})

